﻿using B.S.GridManage.Api.Read.Application.Command.PhisicalGrid;
using B.S.GridManage.Api.Read.Dtos;
using B.S.GridManage.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManage.Api.Read.Controllers
{
    /// <summary>
    /// 物理网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhsicalGridController : ControllerBase
    {
        private readonly IMediator mediator;

        public PhsicalGridController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 搜索物理网格
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<PhysicalGridDto>>> SearchPhysical([FromQuery]SearchPhysicalCommand request) {
            return mediator.Send(request);
        }

        /// <summary>
        /// 批量复制物理网格
        /// </summary>
        /// <param name="request">批量选中的数组,数组中为物理网格</param>
        /// <returns>响应包装类</returns>
        [HttpPost]
        public   Task<ApiResult<int>> CopyPhsicalGrid(CopyPhsicalGridCommand request) {
            return mediator.Send(request);
        }
    }
}
